package com.yic.module.device.dal.mysql.inspectionPlan;

import java.util.*;

import com.yic.framework.common.pojo.PageResult;
import com.yic.framework.mybatis.core.query.LambdaQueryWrapperX;
import com.yic.framework.mybatis.core.mapper.BaseMapperX;
import com.yic.module.device.dal.dataobject.inspectionPlan.InspectionPlanDO;
import org.apache.ibatis.annotations.Mapper;
import com.yic.module.device.controller.admin.inspectionPlan.vo.*;

/**
 * 巡检计划 Mapper
 *
 * @author 系统管理员
 */
@Mapper
public interface InspectionPlanMapper extends BaseMapperX<InspectionPlanDO> {

    default PageResult<InspectionPlanDO> selectPage(InspectionPlanPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<InspectionPlanDO>()
                .likeIfPresent(InspectionPlanDO::getName, reqVO.getName())
                .eqIfPresent(InspectionPlanDO::getStatus, reqVO.getStatus())
                .betweenIfPresent(InspectionPlanDO::getStartDate, reqVO.getStartDate())
                .betweenIfPresent(InspectionPlanDO::getEndDate, reqVO.getEndDate())
                .eqIfPresent(InspectionPlanDO::getType, reqVO.getType())
                .eqIfPresent(InspectionPlanDO::getUserId, reqVO.getUserId())
                .betweenIfPresent(InspectionPlanDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(InspectionPlanDO::getId));
    }

    default List<InspectionPlanDO> selectList(InspectionPlanExportReqVO reqVO) {
        return selectList(new LambdaQueryWrapperX<InspectionPlanDO>()
                .likeIfPresent(InspectionPlanDO::getName, reqVO.getName())
                .eqIfPresent(InspectionPlanDO::getStatus, reqVO.getStatus())
                .betweenIfPresent(InspectionPlanDO::getStartDate, reqVO.getStartDate())
                .betweenIfPresent(InspectionPlanDO::getEndDate, reqVO.getEndDate())
                .eqIfPresent(InspectionPlanDO::getType, reqVO.getType())
                .eqIfPresent(InspectionPlanDO::getUserId, reqVO.getUserId())
                .betweenIfPresent(InspectionPlanDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(InspectionPlanDO::getId));
    }

    default PageResult<InspectionPlanDO> selectAppPage(InspectionPlanPageReqVO reqVO){
        return selectPage(reqVO, new LambdaQueryWrapperX<InspectionPlanDO>()
                .likeIfPresent(InspectionPlanDO::getName, reqVO.getName())
                .eqIfPresent(InspectionPlanDO::getStatus, reqVO.getStatus())
                .betweenIfPresent(InspectionPlanDO::getStartDate, reqVO.getStartDate())
                .betweenIfPresent(InspectionPlanDO::getEndDate, reqVO.getEndDate())
                .eqIfPresent(InspectionPlanDO::getType, reqVO.getType())
                .eqIfPresent(InspectionPlanDO::getUserId, reqVO.getUserId())
                .betweenIfPresent(InspectionPlanDO::getCreateTime, reqVO.getCreateTime())
                .inSql(InspectionPlanDO::getId,"select plan_id from device_inspection_plan_job where status = 0 and deleted = 0 ")
                .orderByDesc(InspectionPlanDO::getId));
    }
}
